#include"comm.h"
#include<string.h>
//客户端:以写方式打开命名管道文件 -> 处理业务逻辑->最后要记得关闭文件描述符
int main()
{
    int fd = open(MY_FIFO,O_WRONLY);
    if(fd < 0)
    {
        perror("open:");
        exit(1);
    }
    while(1)
    {
        char buff[128] = {0};
        memset(buff,0,sizeof(buff));
        printf("enter Message:");
        fflush(stdout);
        ssize_t n = read(0,buff,sizeof(buff)-1);//从键盘读取内容
        if(n > 0)
        {
            buff[n-1] = '\0';//hello\n\0   把\n位置搞成\0
            printf("clisent send:%s\n",buff);
            write(fd,buff,strlen(buff));//把数据写入到管道,\0不写入,所以是strlen(buff)
        }
    }
    close(fd);
    return 0;
}